/**
 * 
 */
package com.Hib.Recipes;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import com.Hib.Domain.Contact;
import com.Hib.Domain.Order1;
import com.Hib.Domain.Phone;
import com.Hib.Util.SessionManager;

/**
 * @author Ignatiues charles arun
 * 
 *         Sep 4, 2010
 */
public class CustomerDAO1
	{

		private static SessionFactory sessionFactory;

		/**
		 * @param args
		 */
		public static void main(String[] args)
			{
				Session session = (Session) getSession().openSession();
				session.beginTransaction();
				Order1 objOrd1 = new Order1();
				Contact[] objCont = new Contact[2];
				objCont[0] = new Contact();
				objCont[1] = new Contact();
				Phone[] objPhone = new Phone[2];
				objPhone[0] = new Phone();
				objPhone[1] = new Phone();

				objOrd1.setHoliDay_Contact(objCont[0]);
				objOrd1.getHoliDay_Contact().setAddress("New Jersy");
				objOrd1.getHoliDay_Contact().setRecepient("Ignatiues");
				objOrd1.getHoliDay_Contact().setPhone(objPhone[0]);
				objOrd1.getHoliDay_Contact().getPhone().setAreacode("034");
				objOrd1.getHoliDay_Contact().getPhone().setTelno("2342422333");
				objOrd1.setHoliDay_Contact(objCont[0]);

				objOrd1.setWeekDay_Contact(objCont[1]);
				objOrd1.getWeekDay_Contact().setAddress("Dallas");
				objOrd1.getWeekDay_Contact().setRecepient("Charles arun");
				objOrd1.getWeekDay_Contact().setPhone(objPhone[1]);
				objOrd1.getWeekDay_Contact().getPhone().setAreacode("3211");
				objOrd1.getWeekDay_Contact().getPhone().setTelno("1231121");

				objOrd1.setWeekDay_Contact(objCont[1]);
				session.saveOrUpdate(objOrd1);
				session.beginTransaction().commit();
				session.flush();
				session.close();
			}

		private static SessionFactory getSession()
			{
				SessionFactory sessionFactory = SessionManager
						.getSessionfactory();
				return sessionFactory;
			}

	}
